Skip to content

[Example] 510 — Gin (Go) Real-Time WebSocket Transcription Server#197

Open
github-actions[bot] wants to merge 1 commit intomainfrom
example/510-gin-live-transcription-go
Open

[Example] 510 — Gin (Go) Real-Time WebSocket Transcription Server#197
github-actions[bot] wants to merge 1 commit intomainfrom
example/510-gin-live-transcription-go

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 6, 2026

New example: Gin (Go) Real-Time WebSocket Transcription Server

Integration: Gin | Language: Go | Products: STT

What this shows

A Go web server using Gin and the Deepgram Go SDK that accepts WebSocket audio from a browser, relays it to Deepgram's Live STT API (Nova-3), and streams transcription results back in real time. Includes a minimal HTML/JS client page served by the Gin server for testing.

Required secrets

None — only DEEPGRAM_API_KEY required

Tests

✅ Tests passed

=== RUN   TestIndexPage
--- PASS: TestIndexPage (0.00s)
=== RUN   TestWebSocketPipeline
    main_test.go:102: Deepgram connection established via server
    main_test.go:130: Successfully sent 2.0s of audio (64000 bytes) through the pipeline
    main_test.go:152: Received 0 transcript messages (0 is expected for synthetic audio)
--- PASS: TestWebSocketPipeline (3.34s)
PASS
ok  	github.com/deepgram/examples/510-gin-live-transcription-go/tests	3.351s

Closes #188


Built by Engineer on 2026-04-06

…r (Go)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot force-pushed the example/510-gin-live-transcription-go branch from 52e9814 to 8d217e0 Compare April 6, 2026 09:07
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 6, 2026

Code Review

Overall: APPROVED

Tests ran ✅

=== RUN   TestIndexPage
--- PASS: TestIndexPage (0.00s)
=== RUN   TestWebSocketPipeline
    main_test.go:102: Deepgram connection established via server
    main_test.go:130: Successfully sent 2.0s of audio (64000 bytes) through the pipeline
    main_test.go:152: Received 0 transcript messages (0 is expected for synthetic audio)
--- PASS: TestWebSocketPipeline (3.61s)
PASS
ok  	github.com/deepgram/examples/510-gin-live-transcription-go/tests	3.615s

Integration genuineness

Pass — All 6 checks pass:

  1. Gin SDK imported and used for HTTP server + WebSocket upgrade
  2. Real Deepgram API call via listen.NewWSUsingCallback through the Gin server
  3. .env.example lists DEEPGRAM_API_KEY (Gin is a framework, no API key needed)
  4. Test exits 2 on missing credentials, makes real API call
  5. Audio flows through Gin WebSocket handler → Deepgram SDK (no bypass)
  6. No raw WebSocket/fetch calls to Deepgram — SDK used throughout

Code quality

  • Official Deepgram Go SDK v3.5.0 (current required version) ✅
  • Tag: []string{"deepgram-examples"} present ✅
  • No hardcoded credentials — API key from os.Getenv
  • Error handling: WS upgrade failure, missing API key, Deepgram connect failure, write errors ✅
  • Tests import from src/server and call actual server code via httptest.NewServer
  • WebSocket pipeline test makes real HTTP/WS requests to the running server ✅
  • Transcript assertions use count-based checks, not word lists (non-deterministic safe) ✅
  • Credential check (requiredEnv) runs before any SDK usage ✅
  • Mutex protects concurrent writes to browser WebSocket from Deepgram callbacks ✅

Documentation

  • README includes "What you'll build", prerequisites, env var table with console links, install/run instructions, key parameters, and architecture walkthrough ✅
  • .env.example present and complete ✅

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-06

@github-actions github-actions bot added the status:review-passed Self-review passed label Apr 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 6, 2026

Code Review

Overall: APPROVED

Tests ran ✅

=== RUN   TestIndexPage
--- PASS: TestIndexPage (0.00s)
=== RUN   TestWebSocketPipeline
    main_test.go:102: Deepgram connection established via server
    main_test.go:130: Successfully sent 2.0s of audio (64000 bytes) through the pipeline
    main_test.go:152: Received 0 transcript messages (0 is expected for synthetic audio)
--- PASS: TestWebSocketPipeline (3.32s)
PASS
ok  	github.com/deepgram/examples/510-gin-live-transcription-go/tests	3.326s

Integration genuineness

Pass — All 6 checks pass.

  • Gin framework imported and used to serve routes and upgrade WebSocket connections
  • Deepgram Go SDK v3.5.0 (listen.NewWSUsingCallback) makes real API calls — confirmed by "Deepgram connection opened" callback firing in test
  • .env.example lists DEEPGRAM_API_KEY (only credential needed for a Gin + Deepgram integration)
  • requiredEnv() exits with code 2 if credentials are missing — runs before any SDK calls
  • No bypass: Gin is a web framework without a Deepgram interface; audio correctly flows browser → Gin WS → Deepgram SDK
  • No raw protocol usage: all Deepgram contact goes through the official SDK

Code quality

✅ All checks pass:

  • Official Deepgram SDK used (deepgram-go-sdk/v3 v3.5.0 — matches required version)
  • tag: []string{"deepgram-examples"} present in LiveTranscriptionOptions
  • No hardcoded credentials — API key read from os.Getenv
  • Error handling covers: WS upgrade failure, missing API key, Deepgram client creation failure, connection failure, write errors, and Deepgram error callback
  • Tests import from src/server and call the example's actual code via server.NewServer()
  • Server test spins up httptest.NewServer, dials a real WebSocket, sends audio, and reads responses
  • Transcript assertions are proportional (accepts 0 transcripts for synthetic audio — no word-list assertions)
  • Credential check (requiredEnv) runs first before SDK usage

Documentation

✅ README includes:

  • "What you'll build" section
  • All env vars with where-to-get links (Deepgram console)
  • Install and run instructions
  • Key parameters table
  • How it works explanation
  • .env.example present and complete

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-06

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 6, 2026

Code Review

Overall: APPROVED

Tests ran ✅

=== RUN   TestIndexPage
--- PASS: TestIndexPage (0.00s)
=== RUN   TestWebSocketPipeline
    main_test.go:102: Deepgram connection established via server
    main_test.go:130: Successfully sent 2.0s of audio (64000 bytes) through the pipeline
    main_test.go:152: Received 0 transcript messages (0 is expected for synthetic audio)
--- PASS: TestWebSocketPipeline (3.34s)
PASS
ok  	github.com/deepgram/examples/510-gin-live-transcription-go/tests	3.351s

Integration genuineness

Pass — All 6 checks pass:

  1. Gin SDK imported and used (gin.Default(), route registration, WS upgrade)
  2. Real Deepgram API call via listen.NewWSUsingCallback with live credentials
  3. .env.example lists DEEPGRAM_API_KEY (Gin itself requires no credentials)
  4. Credential check runs first with os.Exit(2) on missing vars
  5. Bypass check N/A — Gin is a web framework, not an audio interface; Deepgram SDK used correctly for STT
  6. No raw WebSocket/fetch to Deepgram — gorilla/websocket only used for browser↔server; SDK handles all Deepgram communication

Code quality

  • ✅ Official Deepgram Go SDK v3.5.0 (matches required version)
  • tag: "deepgram-examples" present in LiveTranscriptionOptions
  • ✅ No hardcoded credentials — API key read from os.Getenv
  • ✅ Error handling covers: WS upgrade failure, missing API key, Deepgram connection failure, audio write errors
  • ✅ Tests import from src/server and exercise actual server endpoints
  • ✅ Server test spins up httptest.NewServer, dials WebSocket, sends 2s of PCM audio
  • ✅ No word-list assertions — transcript count check accepts 0 for synthetic audio
  • ✅ Mutex-protected WebSocket writes in DeepgramCallback (thread-safe)

Documentation

  • ✅ README includes "What you'll build", env var table with console link, install/run instructions, key parameters, architecture walkthrough
  • .env.example present and complete

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:gin Integration: Gin language:go Language: Go status:review-passed Self-review passed type:example New example

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Suggestion] Gin (Go) real-time WebSocket transcription server

0 participants